package com.duguo.dynamicmvc.view.resource;

import org.springframework.core.io.Resource;

import com.duguo.dynamicmvc.support.servlet.NotFoundException;
import com.duguo.dynamicmvc.view.resolver.ViewResolver;

public class ResourceViewResolverImpl implements ViewResolver {

	private ResourceResolver resourceResolver;
	
	public ResourceView resolve(String resourceUrl) throws NotFoundException {
		Resource resource = resourceResolver.resolve(resourceUrl);
		if (resource != null) {
			return new ResourceView(resource);
		}else {
			return null;
		}
	}

	public void setResourceResolver(ResourceResolver resourceResolver) {
		this.resourceResolver = resourceResolver;
	}
}
